/**
 * @class Ext.ux.Filter
 * @extends Ext.util.Observable
 * Filter base class - extend this to create your own filter
 */
Ext.ux.Filter = Ext.extend(Ext.util.Observable, {

			constructor			: function(config) {
				Ext.ux.Filter.superclass.constructor.apply(this, arguments);

				Ext.applyIf(config, {
							title	: config.name,
							options	: []
						});

				Ext.apply(this, config);
				// this.initListeners();
				this.initEvents();

				// this.refresh();
			},

			refresh				: Ext.emptyFn,

			/**
			 * Fired when an event is received from the listenTo component.  By default this simply calls
			 * this.refresh() on every event.  Override in a subclass to alter the behaviour
			 */
			// eventReceived: function() {
			// this.refresh.apply(this, arguments);
			// },
			/**
			 * Sets up listeners if any are specified in configuration.  All events specified
			 * simply cause this.eventReceived() to be invoked
			 */
			// initListeners: function() {
			// if (typeof this.listenTo == 'object') {
			// Ext.each(this.listenTo.events || [], function(listener) {
			// this.listenTo.component.on(listener, this.eventReceived, this);
			// }, this);
			// }
			//   
			// if (typeof this.store != 'undefined') this.store.on('load', this.refresh, this);
			// },
			/**
			 * Sets up events emitted by this component
			 */
			initEvents			: function() {
				this.addEvents(
						/**
						 * @event refreshed
						 * Fires every time the options in this Filter are updated
						 * @param {Ext.ux.Filter} filter This filter instance
						 */
						'refreshed'
				);
			},

			/**
			 * Function for Array.sort() which sorts the field alphabetically
			 */
			sortAlphabetically	: function(a, b) {
				if (!a || !a.text || !b || !b.text)
					return 0;

				var nameA = a.text.toLowerCase();
				var nameB = b.text.toLowerCase();
				if (nameA < nameB)
					return -1;
				if (nameA > nameB)
					return 1;
				return 0;
			}
		});
